package JavaCode;

import java.util.*;

/**
 * @Author Kechelle
 * @Date 2020/9/10 23:25
 * @Version 1.0
 */
public class DeleteRepeat {
    public static String function(String str){
        List list = new ArrayList();
        StringBuffer sb = new StringBuffer();
        char[] chars =str.toCharArray();
        for (char num:chars){
            if(!list.contains(num)){
                sb.append(num);
                list.add(num);
            }
        }
        return sb.toString();
    }
    public static String function1(String str){
        Set<Character> set = new HashSet<>();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < str.length(); i++) {
            if(set.add(str.charAt(i))){
                sb.append(str.charAt(i));
            }
        }
        return sb.toString();
    }
    public static void main(String[] args) {
        String str = "ABCDABCD";
        System.out.println(DeleteRepeat.function(str));
    }
}
